package org.sang.service;

import org.sang.mapper.MenuMapper;
import org.sang.pojo.RespBean;
import org.sang.pojo.dto.MenuDTO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {

    @Resource
    private MenuMapper menuMapper;
    @Override
    public RespBean<Integer> addMenu(MenuDTO menuDTO) {
        int count = menuMapper.addMenu(menuDTO);
        RespBean<Integer> respBean = new RespBean<>(200, "success");
        respBean.setData(count);
        return respBean;
    }

    @Override
    public RespBean<List<MenuDTO>> allMenus() {
        List<MenuDTO> allMenus = menuMapper.allMenus();
        RespBean<List<MenuDTO>> respBean = new RespBean<>(200, "success");
        respBean.setData(allMenus);
        return respBean;
    }

    @Override
    public RespBean<List<MenuDTO>> getMenusByRoleId(Integer roleId) {
        List<MenuDTO> menuList = menuMapper.getMenusByRoleId(roleId);
        RespBean<List<MenuDTO>> respBean = new RespBean<>(200, "success");
        respBean.setData(menuList);
        return respBean;
    }
}
